/*
* Conditions Of Use
*
* This software was developed by employees of the Sigmatrix(Beijing) Corporation.
* This software is provided by sigmatrix as a service and is expressly
* provided "AS IS."  Sigmatrix MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED
* OR STATUTORY, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT
* AND DATA ACCURACY.  Sigmatrix does not warrant or make any representations
* regarding the use of the software or the results thereof, including but
* not limited to the correctness, accuracy, reliability or usefulness of
* the software.
*
* Permission to use this software is contingent upon your acceptance
* of the terms of this agreement.
*
*/
package com.sigmatrix.h5.dao.impl;

import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import com.sigmatrix.h5.dao.SysConfigDao;
import com.sigmatrix.h5.dao.impl.common.impl.BaseDaoImpl;
import com.sigmatrix.h5.entity.SysConfig;
import com.sigmatrix.h5.utils.Utils;

/**
 *@ClassName: SysConfigDaoImpl
 *@Description: 
 *@date 2017年8月9日 上午12:38:58
 */
@Repository
public class SysConfigDaoImpl extends BaseDaoImpl<SysConfig> implements SysConfigDao {
	
	private static final Logger LOGGER = LoggerFactory.getLogger(SysConfigDaoImpl.class);
	
	public String getValueByKey(final String eseCode,final String key){

		final StringBuffer sql = new StringBuffer();
		sql.append("select _value from ");
		sql.append(this.getTname(eseCode));
		sql.append(" where _key = '").append(key).append("'");
		LOGGER.info(sql.toString());
		Map<String, Object> map = jdbcTemplate.queryForMap(sql.toString());
		if (Utils.isNotEmpty(map)) {
			String value = (String) map.get("_value");
			return value;
		}
		else {
			return null;
		}
		//return jdbcTemplate.queryForObject(sql.toString(), String.class);
	}
	
	private String getTname(final String eseCode){
		return getTname(eseCode,"_sys_config");
	}

}
